const Koa = require('koa')
const views = require('koa-views')
const path = require('path')
const app = new Koa()
// 加载模板引擎
app.use(views(path.join(__dirname, '../view'), {
  extension: 'ejs'
}))
app.use( async ( ctx ) => {
  let title = 'hello koa2';
  let name = 'CJTY'; 
  await ctx.render('index', { // 模板ejs的文件名
    title,name // 传给模板的参数
  })
})
app.listen(3000,()=>{
    console.log('[demo] server is starting at port 3000');
})